package com.fowo.api.model.lingxing;


import com.alibaba.fastjson.JSONObject;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fowo.api.common.annotaion.JoinField;
import com.fowo.api.entity.ListingFather;
import com.fowo.api.entity.ShopInfo;
import com.fowo.api.util.LocalDateUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;

/**
 *  listingFather临时表实体类
 *  以及领星与本地的映射关系
 */
@DS("ds24")
@Data
@TableName(value = "listing_father_temp", autoResultMap = true)
public class ListingFatherTemp implements Serializable {

    /**
     * 编号
     */
    @TableField(value = "`id`")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;
    /**
     * 创建时间
     */
    public static final String CREATE_TIME = "";
    @TableField(value = "`last_update_time`")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(title = "更新时间")
    private String createTime;
    /**
     * 删除标记
     */
    public static final String DEL_FLAG = "is_delete";
    @TableField(value = "`del_flag`")
    @TableLogic
    @Schema(title = "删除标记")
    private int delFlag;
    /**
     * 状态
     * 0-停售；1-在售；2-已删除
     */
    public static final String STATUS = "status";
    @TableField(value = "`status`")
    @Schema(title = "状态")
    private String status;
    /**
     * ASIN
     */
    public static final String ASIN = "asin";
    @TableField(value = "`asin`")
    @Schema(title = "ASIN")
    private String asin;

    /**
     * title --
     */
    public static final String TITLE = "item_name";
    @TableField(value = "`title`")
    @Schema(title = "title")
    private String title;
    /**
     * SKU
     */
    public static final String SKU = "local_sku";
    @TableField(value = "`sku`")
    @Schema(title = "SKU")
    private String sku;
    /**
     * 店铺--本地店铺id
     */
    public static final String SHOP = "";
    @TableField(value = "`shop`")
    @JoinField(ShopInfo.class)
    @Schema(title = "店铺")
    private Long shop;
    /**
     * 国家
     */
    public static final String COUNTRY = "marketplace";
    @TableField(value = "`country`")
    @Schema(title = "国家")
    private String country;
    /**
     * 价格
     */
    public static final String PRICE = "price";
    @TableField(value = "`price`")
    @Schema(title = "商品的原价")
    private java.math.BigDecimal price;
    /**
     * FNSKU
     */
    public static final String FNSKU = "fnsku";
    @TableField(value = "`fnsku`")
    @Schema(title = "FNSKU")
    private String fnsku;
    /**
     * 品名
     */
    public static final String PRODUCT_NAME = "local_name";
    @TableField(value = "`product_name`")
    @Schema(title = "品名")
    private String productName;
    /**
     * MSKU
     */
    public static final String MSKU = "seller_sku";
    @TableField(value = "`msku`")
    @Schema(title = "MSKU")
    private String msku;
    /**
     * 父ASIN
     */
    public static final String PARENT_ASIN = "parent_asin";
    @TableField(value = "`parent_asin`")
    @Schema(title = "父ASIN")
    private String parentAsin;
    /**
     * 配送方式
     */
    public static final String DISTRIBUTION_TYPE = "fulfillment_channel_type";
    @TableField(value = "`distribution_type`")
    @Schema(title = "配送方式")
    private String distributionType;
    /**
     * 优惠
     */
    public static final String DISCOUNTS = "listing_price";
    @TableField(value = "`discounts`")
    @Schema(title = "优惠价")
    private java.math.BigDecimal discounts;
    /**
     * 大类排名
     */
    public static final String RANKING = "seller_rank";
    @TableField(value = "`ranking`")
    @Schema(title = "大类排名")
    private String ranking;
    /**
     * 货币
     */
    public static final String CURRENCY = "currency_code";
    @TableField(value = "`currency`")
    @Schema(title = "货币")
    private String currency;
    /**
     * 商品首单时间
     */
    public static final String FIRST_ORDER_DATE = "first_order_time";
    @TableField(value = "`first_order_date`")
    @Schema(title = "商品首单时间")
    private java.util.Date firstOrderDate;

    /**
     * 可售量
     */
    public static final String ANF_FULFILLABLE_QUANTITY = "afn_fulfillable_quantity";
    @TableField(value = "`afn_fulfillable_quantity`")
    @Schema(title = "可售量")
    private Integer afnFulfillableQuantity;
    /**
     * 待调仓
     */
    public static final String RESERVED_FC_TRANSFERS = "reserved_fc_transfers";
    @TableField(value = "`reserved_fc_transfers`")
    @Schema(title = "待调仓")
    private Integer reservedFcTransfers;
    /**
     * 调仓中
     */
    public static final String RESERVED_FC_PROCESSING = "reserved_fc_processing";
    @TableField(value = "`reserved_fc_processing`")
    @Schema(title = "调仓中")
    private Integer reservedFcProcessing;
    /**
     * 待发货
     */
    public static final String RESERVED_CUSTOMER_ORDERS = "reserved_customerorders";
    @TableField(value = "`reserved_customerorders`")
    @Schema(title = "待发货")
    private Integer reservedCustomerorders;
    /**
     * 入库
     */
    public static final String AFN_INBOUND_SHIPPED_QUANTITY = "afn_inbound_shipped_quantity";
    @TableField(value = "`afn_inbound_shipped_quantity`")
    @Schema(title = "在途")
    private Integer afnInboundShippedQuantity;
    /**
     * 不可售
     */
    public static final String AFN_UNSELLABLE_QUANTITY = "afn_unsellable_quantity";
    @TableField(value = "`afn_unsellable_quantity`")
    @Schema(title = "不可售")
    private Integer afnUnsellableQuantity;
    /**
     * 计划入库
     */
    public static final String AFN_INBOUND_WORKING_QUANTITY = "afn_inbound_working_quantity";
    @TableField(value = "`afn_inbound_working_quantity`")
    @Schema(title = "计划入库")
    private Integer afnInboundWorkingQuantity;
    /**
     * 入库中
     */
    public static final String AFN_INBOUND_RECEIVING_QUANTITY = "afn_inbound_receiving_quantity";
    @TableField(value = "`afn_inbound_receiving_quantity`")
    @Schema(title = "入库中")
    private Integer afnInboundReceivingQuantity;
    /**
     * 运费
     */
    public static final String SHIPPING = "shipping";
    @TableField(value = "`shipping`")
    @Schema(title = "运费")
    private String shipping;
    /**
     * 积分
     */
    public static final String POINTS = "points";
    @TableField(value = "`points`")
    @Schema(title = "积分")
    private String points;
    /**
     * 评论条数
     */
    public static final String REVIEW_NUM = "review_num";
    @TableField(value = "`review_num`")
    @Schema(title = "评论条数")
    private Integer reviewNum;
    /**
     * 星级评分
     */
    public static final String LAST_STAR = "last_star";
    @TableField(value = "`last_star`")
    @Schema(title = "星级评分")
    private String lastStar;
    /**
     * 亚马逊定义的listing的id
     */
    public static final String LISTING_ID = "listing_id";
    @TableField(value = "`listing_id`")
    @Schema(title = "亚马逊定义的listing的id")
    private String listingId;
    /**
     * 店铺id--领星上的店铺id
     */
    public static final String S_ID = "sid";
    @TableField(value = "`sid`")
    @Schema(title = "店铺id")
    private String shopCode;
    /**
     * 产品id
     */
    public static final String PID = "";
    @TableField(value = "`pid`")
    @Schema(title = "产品id")
    private Long pairProduct;

    public static final String SYNC_FLAG = "";
    @TableField(value = "sync_flag")
    @Schema(title = "同步标识")
    private Long syncFlag;
    /**
     * 批次号
     */
    @TableField(value = "'batch_number'")
    private Integer batchNumber;
    public ListingFatherTemp(JSONObject listingFather) {
        this.id = IdWorker.getId(new ListingFather());
        this.createTime = LocalDateUtils.getTodayNow();
        this.status = listingFather.getString(STATUS);
        if(listingFather.getIntValue(DEL_FLAG) == 1){
            this.status = "2";
        }
        this.asin = listingFather.getString(ASIN);
        this.title = listingFather.getString(TITLE);
        this.sku = listingFather.getString(SKU);
        //this.shop
        this.country = listingFather.getString(COUNTRY);
        this.price = listingFather.getBigDecimal(PRICE);
        this.fnsku = listingFather.getString(FNSKU);
        this.productName = listingFather.getString(PRODUCT_NAME);
        this.msku = listingFather.getString(MSKU);
        this.parentAsin = listingFather.getString(PARENT_ASIN);
        this.distributionType = listingFather.getString(DISTRIBUTION_TYPE);
        this.discounts = listingFather.getBigDecimal(DISCOUNTS);
        this.ranking = listingFather.getString(RANKING);
        this.currency = listingFather.getString(CURRENCY);
        this.afnFulfillableQuantity = listingFather.getInteger(ANF_FULFILLABLE_QUANTITY);
        this.reservedFcTransfers = listingFather.getInteger(RESERVED_FC_TRANSFERS);
        this.reservedFcProcessing = listingFather.getInteger(RESERVED_FC_PROCESSING);
        this.reservedCustomerorders = listingFather.getInteger(RESERVED_CUSTOMER_ORDERS);
        this.afnInboundShippedQuantity = listingFather.getInteger(AFN_INBOUND_SHIPPED_QUANTITY);
        this.afnUnsellableQuantity = listingFather.getInteger(AFN_UNSELLABLE_QUANTITY);
        this.afnInboundWorkingQuantity = listingFather.getInteger(AFN_INBOUND_WORKING_QUANTITY);
        this.afnInboundReceivingQuantity = listingFather.getInteger(AFN_INBOUND_RECEIVING_QUANTITY);
        this.shipping = listingFather.getString(SHIPPING);
        this.points = listingFather.getString(POINTS);
        this.reviewNum = listingFather.getInteger(REVIEW_NUM);
        this.lastStar = listingFather.getString(LAST_STAR);
        this.listingId = listingFather.getString(LISTING_ID);
        this.shopCode = listingFather.getString(S_ID);
        this.firstOrderDate = listingFather.getDate(FIRST_ORDER_DATE);
        //this.batchNumber
    }
}
